To do the conversion, you want to calculate total inches and then convert to metric. So following from the snippet above: tot_inches = feet*12 + inches meters = tot_inches * 0.0254 As for input vs raw_input, it would help to know which version of Python you're using, as raw_input is a 2.X feature (not usable in 3.X).
Share, comment, bookmark or report
0.0343 cm/μs = 1 / 0.0343 = 29.155 μs/cm. Sound travels at 343 meters per second, which means it needs 29.155 microseconds per centimeter. So, we have to divide the duration by 29 and then by 2, because the sound has to travel the distance twice. It travels to the object and then back to the sensor. 1 cm = 0,393701 in.
Share, comment, bookmark or report
1. A good method would be to convert meters to inches. Then calculate the number of whole feet from those inches. Finally, calculate the remainder of inches in excess of the feet. Something like this (not exact code): int feet, totalInches, remainderInches; totalInches = (int) (meters * 39.3701); feet = (int) (totalInches / 12); remainderInches ...
Share, comment, bookmark or report
Try to write some variables that convert inches and pounds to centimeters and kilos. Do not just type in the measurements. Work out the math in Python. So far I have done this: inches = 1 centimeters = 1 convert = centimeters * 2.54 print inches print centimeters print"1 inch is %s centimeters." % convert
Share, comment, bookmark or report
You can also set figure size by passing dictionary to rc parameter with key 'figure.figsize' in seaborn set_theme method (which replaces the set method, deprecated in v0.11.0 (September 2020)) import seaborn as sns. sns.set_theme(rc={'figure.figsize':(11.7,8.27)}) Other alternative may be to use figure.figsize of rcParams to set figure size as ...
Share, comment, bookmark or report
The problem is with bbox_inches='tight' and pad_inches=0. Adding those options makes my plot 4.76 inches wide instead of declared 5 inches. But I want them to save space. So how to solve it? Edit: Well, the answers suggest to remove bbox_inches='tight' and pad_inches=0 and use just the tight_layout(). Then the images is of right size, however ...
Share, comment, bookmark or report
I want to convert feet and inches to centimeters format. Format in my DB is: 4'6" (4 feet, 6 inches) Formula for converting into centimeters. 4*30.48 = 121.92 (convert feet to centimeters = multiply by 30.48) 6*2.54 = 15.24 (convert inches to centimeters = multiply by 2.54) So Result = 121.92 + 15.24 = 137.16 cm eg: Actual Table: inches
Share, comment, bookmark or report
The way you're pairing feet with meters and inches with centimetres is going to get you in a tangle: for various conversions you'll end up with inches greater than 12 or centimetres greater than 100. If I were you I'd maintain only two variables - metres and feet - and apply the conversion between those.
Share, comment, bookmark or report
It is for a project, and the specifics for output are as follows, Enter the number of inches: 12300000 12300000 inches = 194 miles, 226 yards, 2 ft, 0 in. – Robert Nelson Commented Jul 21, 2017 at 19:36
Share, comment, bookmark or report
I am new to programming and I am trying to make a simple unit converter in python. I want to convert units within the metric system and metric to imperial and vice-versa.
Share, comment, bookmark or report
Comments